//
//  SDNSString.h
//  SKinDiary
//
//  Created by pcyang on 16/6/26.
//  Copyright © 2016年 tencent. All rights reserved.
//

#import <Foundation/Foundation.h>

NSString* GetSafeString(NSString *originalStr);

BOOL IsEffectiveString(NSString *originalStr);

@interface SDNSString : NSObject
+(NSString*)stringFromDate:(NSDate*)date;
+(NSString*)simpleStringFromDate:(NSDate*)date;
+(NSString*)shortStringFromDate:(NSDate *)date;
+(NSString*)getTimeStringFromDate:(NSDate*)date;
+(NSString*)getTimeStringFromDateString:(NSString*)dateString;
+(NSString*)getTimeStringFromDateString:(NSString*)dateString formatterString:(NSString*)formatterString;
@end


@interface NSString (Color)
- (UIColor *)toUIColor;
@end

@interface NSString (VPEncode)

- (NSString*)MD5EncodedString;
- (NSString*)URLEncodedString;
- (NSString*)URLDecodedString;
- (NSString*)URLEncodedStringWithCFStringEncoding:(CFStringEncoding)encoding;
- (NSString*)URLDecodedStringWithCFStringEncoding:(CFStringEncoding)encoding;

@end

@interface NSObject (VPEncode)
- (NSString*)MD5EncodedString;
@end


@interface NSString (VPNumber)
- (char)charValue;
- (unsigned char)unsignedCharValue;
- (short)shortValue;
- (unsigned short)unsignedShortValue;
- (unsigned int)unsignedIntValue;
- (long)longValue;
- (unsigned long)unsignedLongValue;
- (unsigned long long)unsignedLongLongValue;
- (NSUInteger)unsignedIntegerValue;
@end


@interface NSString (Image)

- (BOOL)isGif;

@end

@interface NSString (HTML)

- (NSString*)stringByRemovingHTMLTags;

@end

@interface NSString (safe)

- (NSString *)safeString;
- (BOOL)isEmptyString;

@end

/**
 * NSString在正则表达式上的扩展
 */
@interface NSString(Regex)

/**
 * 用正则表达式匹配字符串
 *
 * @return 若匹配成功则返回YES
 */
- (BOOL)isMatchedByRegex:(NSString *)pattern;

/**
 * 用正则表达式匹配字符串
 *
 * @return 若匹配成功则返回第一个找到的string
 */
- (NSString *)stringByRegex:(NSString *)pattern;

/**
 * 用正则表达式替换字符串
 *
 * @param templateString 要替换成的字符串模板，形如 \1abc\2
 *
 * @return 返回替换后的新字符串
 */
- (NSString *)stringByReplacingOccurrencesOfRegex:(NSString *)pattern withTemplate:(NSString *)templateString;

@end


@interface NSString (Contains)

- (BOOL)myContainsString:(NSString*)other;
@end

@interface NSString (Escape)
- (NSString *)escapeString;

@end

@interface NSString (keyVals)
-(NSDictionary*) getKeyValMap;
@end

@interface NSString (Url)
-(NSDictionary*) getParams;
-(NSString*) getBaseUrl;
-(NSString*) urlByaddParams:(NSDictionary*) params;
@end

@interface NSString (Util)
- (CGSize)sizeWithFont:(UIFont *) font;
- (CGSize)sizeWithFont:(UIFont *)font constrainedToSize:(CGSize)size;
- (CGSize)sizeWithFont:(UIFont *)font constrainedToSize:(CGSize)size lineBreakMode:(NSLineBreakMode)lineBreakMode;
@end

@interface NSString (Random)
+ (NSString *)randomAlphanumericStringWithLength:(NSInteger)length;
+ (NSString *)randomAlphanumericWithLength:(NSInteger)length;
@end